#ifndef _MYSQL_PROXY_H_
#define _MYSQL_PROXY_H_

#define MYSQLPP_MYSQL_HEADERS_BURIED

#include <mysql++/mysql++.h>

using namespace std;

class MysqlProxy
{
private:
	mysqlpp::Connection _conn;
	mysqlpp::Transaction *_p_transaction;
	int _query_error;

public:
	int Init();
	int BeginTransaction();
	void RollBack();
	void Commit();
	int Exec(string sql);
	mysqlpp::StoreQueryResult DoQuery(string sql);
	mysqlpp::StoreQueryResult SelectItemByID(string table_name, string id_name, string id_value);
	int SingleRes2StdString(mysqlpp::StoreQueryResult &res, string &str, char splitChar);
	void MultiRes2StdString(mysqlpp::StoreQueryResult &res, string &str, char splitChar, char wordChar);
    int IsQueryError();
};

#endif
